package com.sky.controller.admin;

import com.sky.constant.RedisKeyConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api
public class ShopConller {
    @Autowired
    private RedisTemplate redisTemplate;

    @PutMapping("/{status}")
    public Result changeShop(@PathVariable("status") Integer status) {
        redisTemplate.opsForValue().set(RedisKeyConstant.SHOP_STATUS_KEY, status);
        return Result.success();
    }
    @GetMapping("/status")
    public Result getShopStatus() {
        Integer o = (Integer)redisTemplate.opsForValue().get(RedisKeyConstant.SHOP_STATUS_KEY);
        return Result.success(o);
    }
}
